<template>
    <div>
        <template v-for="list in data.resume_work">
            <article class="classifylist classifylistworke thisurl" :data-url="'m-edit-work-experience.html?act=resume_work_add&pid=' + data.smartyGet.pid + '&id=' + list.id">
                <section class="title flex-box">
                    <div class="name">{{list.companyname}}</div>
                    <div class="status flex2"></div>
                </section>
                <section class="txt flex-box">
                    <div class="left">{{list.startTime}} - {{list.todate=="1" ? '至今' : list.endTime }} | {{list.jobs}}</div>
                </section>
                <section class="content flex-box">工作职责：{{list.achievements}}</section>
                <div class="deletebtn" @click="deleteWorkExp(list.id)">删除</div>
            </article>
        </template>
        <div style="padding:15px;">
            <x-button type="primary" @click.native="go('work?pid=')">添加工作经历</x-button>
        </div>
    </div>
</template>
<script>
import {
    XButton,
    XHeader
} from 'vux'


let demoData = [{
    id: 1,
    companyname: "杭州知达",
    startTime: "2016-1-2",
    endTime: "2016-1-2",
    jobs: "工作",
    achievements: "开发完成app",
    todate: 1
}];
export default {
    components: {
        XButton,
        XHeader
    },
    mounted: function() {
        // this.getData(); //暂时注释,php数据接口有问题.
    },
    updated: function() {

    },
    methods: {
        
        getData: function() {
            
        },
        deleteWorkExp: function(workid) {
            //var workid = $(this).attr("data");
            //event.stopPropagation();
            this.$vux.confirm.show({
                title: '工作经历',
                content: '确定要删除该工作经历吗？',
                onShow() {
                    console.log('plugin show')
                },
                onHide() {
                    console.log('plugin hide')
                },
                onCancel() {
                    console.log('取消删除！')
                },
                onConfirm() {
                    console.log('删除成功！')
                    $.get(d7app.apiHost + "personal/user.php?act=resume_work_del", {
                        work_id: workid
                    }, function(data) {
                        if (data == "ok") {
                            alert('删除成功！');
                            console.log('删除成功！')
                        } else if (data == "err") {
                            alert('删除失败!');
                            console.log('删除失败!')
                        }
                    })
                }
            })
        }
    },
    data() {
        return {

            data: {
                resume_work: demoData,
                smartyGet: {}
            }
        }
    }
}
</script>
<style scoped>

</style>
